<template>
  <div class='addProject-container'>
    <el-row>
      <el-col :span="24">
      </el-col>
      <el-col :span="12"
              class="pro-form">
        <!--   <el-form-item label="是否工业化项目"
                      prop="is_indust_project">
          <el-radio-group :disabled="isZljz==true||status==='detail'"
                          @change="onIndustryPro"
                          v-model="objRowRequest.is_indust_project">
            <el-radio label="1">是</el-radio>
            <el-radio label="0">否</el-radio>
          </el-radio-group>
        </el-form-item> -->

        <!-- 基础项目信息  
                        -->
        <div class="base-project-info">
          <el-form-item label="项目代码"
                        :prop="isZljz==true?'project_code':''">
            <div class="common-row-style">
              <el-tooltip class="item"
                          effect="dark"
                          content="点击当前页面的任意空白处(失去焦点),判断当前项目编码是否已经存在"
                          placement="top">
                <el-input v-model="objRowRequest.project_code"
                          :disabled="status=='detail'"
                          @blur="onProCodeKeyUp(objRowRequest.project_code)"
                          placeholder="请输入项目代码"></el-input>
              </el-tooltip>
              <el-tooltip class="item"
                          effect="dark"
                          :disabled="status==='detail'"
                          content="注:项目代码应采用浙江政务服务网投资项目在线审批监管平台
                          (工程建设项目全流程审批管理系统)规定的项目代码"
                          placement="right">
                <el-button icon="el-icon-question"
                           :disabled="status==='detail'"
                           type="text"></el-button>
              </el-tooltip>
            </div>
          </el-form-item>
          <el-form-item label="项目名称"
                        prop="project_name">
            <div class="pro-name-style common-row-style">
              <el-input :disabled="status==='detail'"
                        placeholder="请输入项目名称"
                        v-model="objRowRequest.project_name"></el-input>
              <div v-if="objRowRequest.is_indust_project==1"
                   class="bind-project">
                <el-button type="primary"
                           @click="onSyncZheLiIndPro">获取浙里建项目数据</el-button>
              </div>
              <!-- v-auth="'bind-project'" -->
              <div class="bind-project">
                <!-- 未绑定项目时 -->
                <!-- v-if="objRowRequest.jt_project_id===0 && projectStatus!=='detail'" -->
                <el-button @click="bindOuterProjectDialog"
                           v-if="objRowRequest.jt_project_id===0 && status!='detail' && isShow=='1'"
                           type="primary">绑定建投项目数据</el-button>
                <!-- 已绑定项目时    v-if="objRowRequest.jt_project_id!==0 && projectStatus!=='detail'"-->
                <el-tooltip v-if="objRowRequest.jt_project_id!==0 && status!='detail' && isShow=='1'"
                            effect="dark"
                            :content="`已绑定项目：${objRowRequest.jt_project_name}`"
                            placement="top">
                  <el-button @click="bindOuterProjectDialog"
                             type="primary">绑定建投项目数据</el-button>
                </el-tooltip>
                <!-- 已绑定项目且处于详情页时 -->
                <el-button type="text"
                           :disabled="status==='detail'"
                           v-if="objRowRequest.jt_project_id!==0 && status==='detail'">
                  {{'已绑定项目：'+objRowRequest.jt_project_name}}
                </el-button>
              </div>
            </div>
          </el-form-item>
          <el-form-item label="项目简称"
                        prop="nick_name">
            <div class="common-row-style">
              <el-input placeholder="请输入项目简称"
                        :disabled="status==='detail'"
                        v-model="objRowRequest.nick_name"></el-input>
              <el-tooltip class="item"
                          effect="dark"
                          :disabled="status==='detail'"
                          content="项目简称，方便手机显示项目名称"
                          placement="right">
                <el-button icon="el-icon-question"
                           :disabled="status==='detail'"
                           type="text"></el-button>
              </el-tooltip>
            </div>
          </el-form-item>
          <el-form-item label="项目二维码"
                        v-show="status==='detail'">
            <div class="pro-code-style common-row-style">
              <div id="qrcode"></div>
              <el-button @click="downLoad"
                         size="medium"
                         type="success"
                         class="imm-down">立即下载</el-button>
            </div>
          </el-form-item>
          <el-form-item label="建筑类型">
            <el-select v-model="objRowRequest.building_type"
                       class="normal-input"
                       :disabled="status==='detail'"
                       placeholder="选择建筑类型">
              <el-option v-for="item in buildingTypeList"
                         :key="item.value"
                         :label="item.name"
                         :value="item.value">
              </el-option>
            </el-select>
          </el-form-item>
          <!-- objRowRequest.business_type -->
          <el-form-item label="业务身份"
                        prop="business_type">
            <!-- multiple business_type_list -->
            <el-select v-model="businessType"
                       class="normal-input"
                       multiple
                       :disabled="status==='detail'"
                       placeholder="选择业务身份"
                       @change="chooseBusinessType">
              <el-option v-for="item in businessTypeList"
                         :key="item.value"
                         :label="item.name"
                         :value="item.value"
                         :disabled="item.content1===''">
              </el-option>
            </el-select>
          </el-form-item>
          <!-- <el-form-item prop=""
                        v-if="businessType.indexOf('10') !== -1"
                        class="normal-input"
                        label="监管级别">
            <el-select v-model="objRowRequest.level"
                       class="unit-name"
                       placeholder="请选择监管级别">
              <el-option v-for="item in superviseArr"
                         :key="item.value"
                         :label="item.name"
                         :value="item.value">
              </el-option>
            </el-select>
          </el-form-item> -->

          <el-form-item label="项目经理">
            <el-input placeholder="请输入项目经理"
                      :disabled="status==='detail'"
                      v-model="objRowRequest.leader_name"></el-input>
          </el-form-item>
          <el-form-item label="项目部"
                        prop="dept_no">
            <el-select v-model="objRowRequest.dept_no"
                       class="normal-input"
                       :disabled="status==='detail'"
                       placeholder="请选择项目部门"
                       @focus="openManageDialog">
              <el-option v-for="item in depArr"
                         :key="item.key"
                         :label="item.label"
                         :value="item.value"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="项目地址"
                        prop="city_no">
            <LocationSelect ref="locationSelect"
                            :currentProBaseInfoComp.sync="currentProBaseInfoComp"
                            :callBackLocationFunc="callBackLocationFunc"
                            :statusVal.sync="status"
                            :locaData.sync="objRowRequest"></LocationSelect>
          </el-form-item>
          <!-- v-if="isShowFormItem('address')" -->
          <el-form-item label="详细地址">
            <el-input :disabled="status==='detail'"
                      placeholder="请输入详细地址"
                      v-model="objRowRequest.address"></el-input>
          </el-form-item>
          <el-form-item label="地图位置"
                        prop="lonlat">
            <el-input @focus="selectNewMap"
                      :disabled="status==='detail'"
                      readonly
                      :value="objRowRequest.lonlat">
            </el-input>
          </el-form-item>
          <el-form-item label="施工许可证编号"
                        prop="project_license_no">
            <el-input v-model="objRowRequest.project_license_no"
                      :disabled="status==='detail'"
                      placeholder="请输入施工许可证编号"></el-input>
          </el-form-item>
          <el-form-item label="项目效果图"
                        prop="">
            <el-upload class="avatar-uploader"
                       action=""
                       :disabled="status==='detail'"
                       :show-file-list="false"
                       :on-success="handleAvatarSuccess"
                       :before-upload="beforeAvatarUpload"
                       :http-request="uploadProjectImg">
              <img v-if="objRowRequest.img"
                   :src="objRowRequest.img"
                   class="avatar">
              <i v-else
                 class="el-icon-plus avatar-uploader-icon"></i>
            </el-upload>
          </el-form-item>

          <el-form-item label="劳资负责人"
                        v-if="objRowRequest.is_indust_project !== '1'">
            <el-input placeholder="请输入劳资负责人"
                      :disabled="status==='detail'"
                      v-model="objRowRequest.labor_capital_leader_name"></el-input>
          </el-form-item>
          <el-form-item label="劳务员"
                        v-if="objRowRequest.is_indust_project!=='1'">
            <el-input placeholder="请输入劳务员"
                      :disabled="status==='detail'"
                      v-model="objRowRequest.laborer"></el-input>
          </el-form-item>
          <el-form-item label="分包范围"
                        v-if="objRowRequest.is_indust_project!== '1' ">
            <el-input placeholder="请输入分包范围"
                      :disabled="status==='detail'"
                      type="textarea"
                      :rows="3"
                      v-model="objRowRequest.subcontract_scope"></el-input>
          </el-form-item>
        </div>
        <!-- <div v-if="status!=='detail'"
             class="back"> -->
        <!-- 普通项目保存 -->
        <!-- <el-button @click="editProject"
                     v-if="objRowRequest.is_indust_project==='2'"
                     type="primary">提交</el-button> -->
        <!-- 1369项目保存 -->
        <!-- <el-button @click="editExtProject"
                     v-if="objRowRequest.is_indust_project==='1' && projectStep===2"
                     type="primary">保存</el-button> -->
        <!-- @click="nextStep('edit')" -->
        <!-- <el-button @click="editProject"
                     type="primary">提交</el-button>
          <el-button @click="onBack">取消</el-button>
        </div> -->
        <!-- <div v-if="status==='detail'"
             class="back">
          <el-button @click="nextStep('detail')"
                     type="primary"
                     v-if="objRowRequest.is_indust_project==='1' && projectStep===1">下一步</el-button>
          <el-button @click="onBack">返回</el-button>
        </div> -->
      </el-col>
      <el-col :span="12"
              v-if="objRowRequest.is_indust_project === '0'"
              class="right-box">
        <span class="title-style">提示：该列信息的数据填写后，将在监控台大屏页面中展示</span>
        <el-form-item label="合同开工日期"
                      class="start-date-style"
                      prop="contract_start_date">
          <el-date-picker v-model="objRowRequest.contract_start_date"
                          :disabled="status==='detail'"
                          value-format="yyyy-MM-dd"
                          placeholder="请选择合同开工日期"></el-date-picker>
        </el-form-item>
        <el-form-item label="合同竣工日期"
                      prop="contract_end_date">
          <el-date-picker v-model="objRowRequest.contract_end_date"
                          value-format="yyyy-MM-dd"
                          :disabled="status==='detail'"
                          placeholder="请选择合同竣工日期"></el-date-picker>
        </el-form-item>
        <el-form-item label="合同工期"
                      prop="contract_days">
          <el-input v-model="objRowRequest.contract_days"
                    :disabled="status==='detail'"
                    placeholder="请选择合同工期"> <template slot="append">天</template></el-input>
        </el-form-item>
        <!-- prop="total_build_area" -->
        <el-form-item label="总建筑面积">
          <el-input v-model="objRowRequest.total_build_area"
                    :disabled="status==='detail'"
                    placeholder="请输入总建筑面积">
            <template slot="append">㎡</template>
          </el-input>
        </el-form-item>
        <el-form-item label="用地面积"
                      prop="land_area">
          <el-input v-model="objRowRequest.land_area"
                    :disabled="status==='detail'"
                    placeholder="请输入用地面积">
            <template slot="append">㎡</template>
          </el-input>
        </el-form-item>
        <el-form-item label="地上面积"
                      prop="aboveground_area">
          <el-input v-model="objRowRequest.aboveground_area"
                    :disabled="status==='detail'"
                    placeholder="请输入地上面积">
            <template slot="append">㎡</template>
          </el-input>
        </el-form-item>
        <el-form-item label="地下面积"
                      prop="underground_area">
          <el-input v-model="objRowRequest.underground_area"
                    :disabled="status==='detail'"
                    placeholder="请输入地下面积">
            <template slot="append">㎡</template>
          </el-input>
        </el-form-item>
        <el-form-item label="容积率"
                      prop="plot_rate">
          <el-input v-model="objRowRequest.plot_rate"
                    :disabled="status==='detail'"
                    placeholder="请输入容积率">
          </el-input>
        </el-form-item>
        <el-form-item label="绿化率"
                      prop="greening_rate">
          <el-input v-model="objRowRequest.greening_rate"
                    :disabled="status==='detail'"
                    placeholder="请输入绿化率">
          </el-input>
        </el-form-item>
        <el-form-item label="装配率">
          <!-- prop="assembly_rate" -->
          <el-input v-model="objRowRequest.assembly_rate"
                    :disabled="status==='detail'"
                    placeholder="请输入装配率">
          </el-input>
        </el-form-item>
        <el-form-item label="建设单位名称"
                      prop="build_company">
          <el-input v-model="objRowRequest.build_company"
                    :disabled="status==='detail'"
                    class="normal-input"
                    placeholder="请输入建设单位名称"></el-input>
        </el-form-item>
        <el-form-item label="建设单位负责人">
          <el-input placeholder="请输入建设单位负责人"
                    :disabled="status==='detail'"
                    class="normal-input"
                    v-model="objRowRequest.build_leader_name"></el-input>
        </el-form-item>
        <el-form-item label="设计单位">
          <el-input placeholder="请输入设计单位"
                    :disabled="status==='detail'"
                    class="normal-input"
                    v-model="objRowRequest.design_company"></el-input>
        </el-form-item>
        <el-form-item label="设计单位负责人">
          <el-input placeholder="请输入设计单位负责人"
                    :disabled="status==='detail'"
                    class="normal-input"
                    v-model="objRowRequest.design_leader_name"></el-input>
        </el-form-item>
        <el-form-item label="施工单位">
          <el-input placeholder="请输入施工单位"
                    :disabled="status==='detail'"
                    class="normal-input"
                    v-model="objRowRequest.construction_company"></el-input>
        </el-form-item>
        <el-form-item label="施工单位负责人">
          <el-input placeholder="请输入施工单位负责人"
                    :disabled="status==='detail'"
                    class="normal-input"
                    v-model="objRowRequest.construction_leader_name"></el-input>
        </el-form-item>
        <el-form-item label="勘察单位">
          <el-input placeholder="请输入勘察单位"
                    :disabled="status==='detail'"
                    class="normal-input"
                    v-model="objRowRequest.survey_company"></el-input>
        </el-form-item>
        <el-form-item label="勘察单位负责人">
          <el-input placeholder="请输入勘察单位负责人"
                    :disabled="status==='detail'"
                    class="normal-input"
                    v-model="objRowRequest.survey_leader_name"></el-input>
        </el-form-item>
        <el-form-item label="监理单位">
          <el-input placeholder="请输入监理单位"
                    :disabled="status==='detail'"
                    class="normal-input"
                    v-model="objRowRequest.supervisor_company"></el-input>
        </el-form-item>
        <el-form-item label="监理单位负责人">
          <el-input placeholder="请输入监理单位负责人"
                    :disabled="status==='detail'"
                    class="normal-input"
                    v-model="objRowRequest.supervisor_leader_name"></el-input>
        </el-form-item>
      </el-col>
    </el-row>
    <Map :mapLngLat.sync="objRowRequest"
         :dialogVisible.sync="mapDialogVisible"></Map>
    <NewMap :mapLngLat.sync="objRowRequest"
            :currentProBaseInfoComp.sync="currentProBaseInfoComp"
            :callBackLonlat="callBackLonlat"
            :dialogVisible.sync="newmapDialogVisible"></NewMap>

    <!-- 选择项目部弹框 -->
    <el-dialog title="选择项目部"
               :visible.sync="organizationDialogVisible"
               width="40%">
      <el-row>
        <el-col :span='12'>
          <OrganizationTree :curMenu.sync="selectedNode"
                            :deptSort="2"
                            :selectProject='true'></OrganizationTree>
        </el-col>
      </el-row>
      <span slot="footer"
            class="dialog-footer">
        <el-button @click="organizationDialogVisible = false">取 消</el-button>
        <el-button type="primary"
                   @click="selectDept">确 定</el-button>
      </span>
    </el-dialog>

    <el-dialog title="绑定项目"
               top="5vh"
               width="80%"
               :visible.sync="bindProjectDialogVisible">
      <ConstructProjectList pageType='component'
                            :choosedRow.sync="choosedRow"></ConstructProjectList>
      <div slot="footer">
        <el-button @click="bindProjectDialogVisible = false">取 消</el-button>
        <el-button type="primary"
                   @click="bindProject">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { operaProjectMixin } from '@/mixins/operaProjectMixins'
import QRCode from 'qrcodejs2';//二维码
import LocationSelect from '@/components/LocationSelect/LocationSelect'
import Map from '@/components/Map/Map'
import NewMap from '@/components/Map/NewMap'
import { UploadFileApi, userPermissionApi } from '@/services/UserPermission'
import { ProjectListApi } from '@/services/ProjectCenter'
import { standardCodeApi } from '@/services/StandardCode'
import OrganizationTree from '@/components/OrganizationTree/OrganizationTree'
import { organizationApi } from '@/services/CompanySetting'
import JobUserList from '@/pages/ConfigCenter/CompanySetting/components/JobUserList'
import ConstructProjectList from '@/pages/ProjectCenter/ConstructProjectList'
import { util } from "@/helper";
export default {
  mixins: [operaProjectMixin],
  data () {
    return {
      superviseArr: [{
        value: 1,
        name: '省级'
      }, {
        value: 2,
        name: '市级'
      }, {
        value: 3,
        name: '县级'
      }],
      isShow: '',
      projectId: 0,
      currentProBaseInfoComp: 'tab基本信息组件',//当前组件-新增项目-tab基本信息组件
    }
  },
  components: {
    LocationSelect,
    Map,
    NewMap,
    OrganizationTree,
    JobUserList,
    ConstructProjectList
  },
  props: {
    isZljz: {
      type: Boolean,
      default: () => {
        return false
      }
    },
    businessType: {
      type: Array,
      default: () => {
        return []
      }
    },
    isDustryPro: {//是否为工业化
      type: Boolean,
      default: () => {
        return false
      }
    },
    //   status: String,    
  },
  watch: {
    status (newval, oldval) {
      this.projectStatus = newval
    },
    selectLeaderNode: {
      handler (newval, oldval) {
        let tempData = {}
        tempData.node_type = newval.node_type
        tempData.user_name = ''
        if (newval.node_type === '1') {
          tempData.org_no = newval.org_no
        } else if (newval.node_type === '2') {
          tempData.dept_no = newval.no
        } else if (newval.node_type === '3') {
          tempData.job_id = newval.id
        }
        this.getJobUserListParam = Object.assign(this.getJobUserListParam, tempData)

      },
      deep: true
    },
    selectedNode: {
      handler (newval, oldval) {
        // console.log('adc====>', newval)
      },
      deep: true
    },
    // 表格点击行数据
    tableRowData: {
      handler (newval, oldval) {
        // console.log('row====>', newval)
      }
    }
  },
  methods: {
    //判断登录单位是否是建投,是就显示
    isShowBtn () {
      ProjectListApi.isJianCompany({}).then((res) => {
        if (res.code == 0) {
          this.isShow = res.data.is_jiantou
        }
      })
    },
    getProvinceUpdateInfo (val) {
      this.objRowRequest.province = val.province;
      this.objRowRequest.province_no = val.province_no;
      this.objRowRequest.city = val.city;
      this.objRowRequest.city_no = val.city_no;
      this.objRowRequest.area = val.area;
      this.objRowRequest.area_no = val.area_no;
    },
    callBackLocationFunc (val) {//省市区县
      this.getProvinceUpdateInfo(val);//省市区县值更新
      // console.log('省市区县', val)
    },
    callBackLonlat (val, lon, lat) {//经伟度
      this.objRowRequest.lonlat = val;
      this.objRowRequest.lon = lon;
      this.objRowRequest.lat = lat;
      // console.log('经伟度', val)
    },
    onIndustryPro (val) {//是否工业化项目
      let isIndustry = false
      if (val == 1) {
        isIndustry = true;
      };
      this.$emit('update:isDustryPro', isIndustry);//是否工业化项目值更新
    },
    // 获取组织树数据
    getOrgTree () {
      return organizationApi.getOrgTree({
        data: {
          node_type: '2'
        }
      }).then(res => {
        // console.log(res, 'get org tree')
        let data = res.data
        this.projectInfoDetailData = data;
        this.$store.dispatch('setOrgainzationTree', data)
        window.localStorage.setItem('platformOrganizationTree', JSON.stringify(data))
      }, err => {
        console.log(err)
      })
    },
    getProjectInfo (projectId) {//项目详情 
      //项目详情
      let local = JSON.parse(window.localStorage.getItem('editProjectInfo') || '{}')
      this.projectId = local.id || 0;//
      let projectIdV = this.$route.query.project_id || this.projectId;
      window.localStorage.setItem('editProjectInfo', JSON.stringify({ id: projectIdV }))
      console.log('测试项目主键值 projectId=', projectId)
      // window.localStorage.setItem('editProjectInfo', JSON.stringify({}))
      ProjectListApi.getProjectInfo({
        params: {
          project_id: projectId,//项目主键值
          flag: 'sync' //同步状态
        }
      }).then((res) => {
        let businessTyp = []
        let isIndustryPro = res.data.is_indust_project;//是否工业化项目
        if (isIndustryPro == 1) {
          this.$emit('update:isDustryPro', true)
        } else {
          this.$emit('update:isDustryPro', false)
        }
        //同步信息时业务身份不回显  1.1.7改
        if (res.data.business_type === '') {
          businessTyp = []
        } else {
          let businessTypeV = res.data.business_type;
          businessTyp = businessTypeV.split(',');//业务身份
        }
        let data = res.data;
        let lon = res.data.lon;
        let lat = res.data.lat;
        // let businessTypeV = res.data.business_type;
        // let businessTyp = businessTypeV.split(',');//业务身份
        this.$set(data, 'dept_no', '');//部门为空        
        this.$emit('update:deptArr', []);
        this.$emit('update:businessType', businessTyp);
        this.$set(data, 'lonlat', lon + '-' + lat);//经纬度
        let obj = res.data;
        this.$set(obj, 'is_sync', 1);
        this.$emit('update:objRowRequest', res.data);
      }).catch((error) => {
        console.log(error)
      })
    },
    isSyncCurrentProCode (data) {//是否同步当前的项目代码的所有项目信息
      this.$confirm('该项目已存在,是否同步项目信息?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
        left: true
      }).then(() => {
        this.isSync = 1;//1同步
        this.objRowRequest.is_sync = 1;//不同步
        this.isSyncProjectId = data.project_id;
        this.getProjectInfo(this.isSyncProjectId);
        this.objRowRequest.dept_no = '';//重置
        // this.depArr = [];//重置
        // this.$emit('update:depArr', []);
      }).catch(() => {
        this.isSync = 0;//0不同步
        this.isSyncProjectId = '';
        this.objRowRequest.is_sync = 0;//不同步
        this.$message({
          type: 'info',
          message: '已取消同步'
        });
      });
    },
    getIsExistProCode (proCode) {//项目代码是否存在
      ProjectListApi.getIsExistProCode({
        params: {
          project_code: proCode,//项目代码值
        }
      }).then((res) => {
        let data = res.data;//当前项目代码的项目信息
        let proCodeV = res.data.project_code;//项目代码值
        if (proCodeV && proCodeV == proCode) {//项目代码存在时
          this.isSyncCurrentProCode(data);//是否同步当前的项目代码
        }
      }).catch((error) => {
        console.log(error)
      })
    },
    onProCodeKeyUp (proCode) {//项目代码
      if (proCode != '') {
        this.getIsExistProCode(proCode);//判断当前项目代码是否已经存在
      }
    },
    onSyncZheLiIndPro () {//获取浙里建项目数据
      // this.$message.warning('开发中,敬请期待')
    },
    // 添加计算书上传容器
    addFileUpload () {
      if (this.objRowRequest.assembly_rate_cal_file.length < 5) {
        this.objRowRequest.assembly_rate_cal_file.push({ url: '' })
      } else {
        this.$message.warning('最多上传5条数据')
      }

    },
    // 装配率计算书上传成功事件
    uploadPictureSuccess (index) {

    },
    // 装配率计算书上传
    uploadPicture (file, item, ref) {
      let formData = new FormData();
      formData.append("module", "industry");
      formData.append("pic_file_apk", file.file);
      UploadFileApi.uploadFile({
        data: formData
      }).then(res => {
        this.$refs[ref][0].clearFiles()
        if (res.data) {
          this.$message.success("上传成功");
          item.url = res.data.file_path
          let str = res.data.file_path.split('industry/industry/')[1] || ''
          let name = str.split('/')[1]
          item.file_name = name
        }
      }, err => {
        this.$refs[ref][0].clearFiles()
      });
    },
    // 下载装配率计算书
    donwloadFile (item) {
      window.open(item.url)
    },
    // 删除构件厂商
    deleteManufacturer (index) {
      this.objRowRequest.component_manufacturer.splice(index, 1)
    },
    // 添加构件厂商
    addManufacturer () {
      this.objRowRequest.component_manufacturer.push({ name: '' })
    },
    chooseStreet () {
      let street = this.streetMap[this.objRowRequest.street_no]
      this.objRowRequest.street = street.street
    },
    // 工业化项目保存
    editExtProject () {
      this.$refs.extForm.validate((valid) => {
        if (valid) {
          this.objRowRequest.project_id = this.objRowRequest.project_id
          this.objRowRequest.province = this.objRowRequest.province
          this.objRowRequest.province_no = this.objRowRequest.province_no
          this.objRowRequest.city = this.objRowRequest.city
          this.objRowRequest.city_no = this.objRowRequest.city_no
          this.objRowRequest.area = this.objRowRequest.area
          this.objRowRequest.area_no = this.objRowRequest.area_no
          if (this.isSync == 1) {
            this.$delete(this.objRowRequest, 'project_ext_id')
          }
          ProjectListApi.projectExtSave({
            data: this.objRowRequest
          }).then(res => {
            if (res.code === 0) {
              this.$message.success('编辑工业化项目成功')
              this.$router.push('/ProjectList')
            }
          })
        }
      })
    },
    // 下一步
    // nextStep (type) {
    //   if (type === 'edit') {//编辑
    //     this.$refs.objRowRequest.validate((valid) => {
    //       if (valid) {//新增/编辑
    //         if (this.projectStatus === 'create' && this.isSync == 0) {//新增
    //           ProjectListApi.createProject({
    //             data: this.objRowRequest
    //           }).then(res => {
    //             if (res.code === 0) {
    //               this.$message.success('新增项目成功');
    //               this.projectStep = 2;
    //               this.objRowRequest.project_id = res.data.project_id;
    //               this.objRowRequest.component_manufacturer = [{ name: '' }];
    //               if (this.isSync == 1) {
    //                 this.objRowRequest.id = this.isSyncProjectId;
    //                 this.getIndustryProjectDetail();//第二次的详情
    //               }
    //             }
    //           })
    //         } else {//编辑
    //           this.objRowRequest.id = this.objRowRequest.project_id
    //           ProjectListApi.updateProject({
    //             data: this.objRowRequest
    //           }).then(res => {
    //             if (res.code === 0) {
    //               this.$message.success('修改项目成功')
    //               this.getIndustryProjectDetail()
    //             }
    //           }, err => {
    //             console.log(err)
    //           })
    //         }
    //         this.getStreetList()
    //       }
    //     })
    //   } else {
    //     this.getIndustryProjectDetail()
    //   }
    // },
    // 获取工业化项目详情
    // getIndustryProjectDetail () {
    //   ProjectListApi.projectExtDetail({
    //     params: {
    //       project_id: this.isSync == 1 ? this.isSyncProjectId : this.objRowRequest.project_id
    //     }
    //   }).then(res => {
    //     if (res.code === 0) {
    //       this.objRowRequest = Object.assign(this.objRowRequest, res.data)
    //       if (this.objRowRequest.component_manufacturer.length <= 0) {
    //         this.objRowRequest.component_manufacturer = [{ name: '' }]
    //       }
    //       this.objRowRequest.assembly_rate_cal_file.map((item) => {
    //         // 分割文件地址，得到文件名称
    //         if (item.url) {
    //           let str = item.url.split('industry/industry/')[1] || ''
    //           let name = str.split('/')[1]
    //           item.file_name = name
    //         }
    //       })
    //       this.projectStep = 2
    //     }
    //   })
    // },
    // 获取街道列表
    getStreetList () {
      ProjectListApi.getStreetList({
        data: {
          area_type: '4',
          area_no: this.objRowRequest.area_no
        }
      }).then(res => {
        if (res.code === 0) {
          this.streetList = res.data
          this.streetList.map((item) => {
            this.streetMap[item.street_no] = item
          })
        }
      })
    },
    downLoad () {//下载项目二维码
      let myCanvas = document.getElementById('qrcode').getElementsByTagName('canvas');
      let a = document.createElement('a')
      a.href = myCanvas[0].toDataURL('image/png');
      a.download = this.objRowRequest.project_name + '项目二维码';
      a.click()
      this.$message({
        message: "正在进行下载保存",
        type: 'success'
      })
    },
    getQrCode () {//生成二维码
      let objVal = { project_id: this.$route.query.project_id };
      let qrcode = new QRCode('qrcode', {
        width: 132,
        height: 132,
        text: JSON.stringify(objVal), // 二维码地址
        colorDark: "#000",
        colorLight: "#fff",
      });
      qrcode._el.title = "";//隐藏提示
    },
    // 绑定建投项目
    bindOuterProjectDialog () {
      this.bindProjectDialogVisible = true
    },
    bindProject () {
      let keys = Object.keys(this.choosedRow)
      if (keys.length === 0) {
        this.$message.warning('请选择项目')
        return
      }
      let res = util.getLocationNo(this.choosedRow.province, this.choosedRow.city, this.choosedRow.area)
      this.choosedRow.province_no = res.provinceNo
      this.choosedRow.city_no = res.cityNo
      this.choosedRow.area_no = res.areaNo
      this.objRowRequest = Object.assign(this.objRowRequest, this.choosedRow);
      // let businessType = this.objRowRequest.business_type;//业务身份
      // this.objRowRequest.business_type = String(businessType);//类型转换
      this.objRowRequest.address = this.choosedRow.comm_addr
      this.objRowRequest.out_project_id = this.choosedRow.code
      this.objRowRequest.outer_service = 'jt'
      this.bindProjectDialogVisible = false;
    },
    // 打开选择项目弹窗
    openManageDialog () {
      this.organizationDialogVisible = true
    },
    // 选择项目部
    selectDept () {
      if (this.selectedNode.node_type !== '2' || this.selectedNode.dept_type === '1') {
        this.$message.error('请选择项目部');
      } else {
        this.depArr.length = 0
        this.depArr.push({
          key: this.selectedNode.no,
          value: this.selectedNode.no,
          label: this.selectedNode.name
        })
        // this.objRowRequest.dept_no = this.selectedNode.id
        this.objRowRequest.dept_no = this.selectedNode.no
        this.objRowRequest.org_no = this.selectedNode.org_no
        this.organizationDialogVisible = false
      }
    },
    // 上传项目图片
    uploadProjectImg (file) {
      let formData = new FormData()
      formData.append('module', 'industry')
      formData.append('pic_file_apk', file.file)
      UploadFileApi.uploadFile({
        data: formData
      }).then(res => {
        if (res.data) {
          this.$message.success('上传成功')
          // this.objRowRequest.img = res.data.file_name;
          this.objRowRequest.img = res.data.file_path;//全路径
          // this.$set(this.objRowRequest, 'img_url', res.data.file_path)
          // this.objRowRequest.img_url = res.data.file_path;
          // console.log('上传图片 objRowRequest.img_url=', this.objRowRequest.img_url, 'res=', res)
        }
      })
    },
    // 根据接口返回的表单列表判断是否需要展示该表单
    isShowFormItem (name) {
      let flag = this.dynamicForm.includes(name)
      return flag
    },

    // 图片上传功能
    handleAvatarSuccess (res, file) {
      this.imageUrl = URL.createObjectURL(file.raw)
    },
    // 图片上传前的钩子
    beforeAvatarUpload (file) {

    },
    // 选择具体经纬度
    selectMap () {
      this.mapDialogVisible = true
    },
    selectNewMap () {
      this.newmapDialogVisible = true
    },
    // 选择业务身份
    chooseBusinessType (val) {
      let str = ''
      if (val.length > 0) {
        str = val.join(',')
      };
      this.objRowRequest.business_type = str;
    },
    // 获取业务身份标准码
    getBusinessTypeCode () {
      return standardCodeApi.getStandardCodeData({
        data: {
          code_type: 'businessType'
        }
      }).then(res => {
        if (res.code === 0 && res.data.list) {
          this.businessTypeList = res.data.list
          window.localStorage.setItem('platformBusinessTypeCode', JSON.stringify(this.businessTypeList))
        }
      }, err => {
        console.log(err)
      })
    },
    // 获取建筑类型标准码
    getBuildingTypeCode () {
      return standardCodeApi.getStandardCodeData({
        data: {
          code_type: 'buildingType'
        }
      }).then(res => {
        if (res.code === 0 && res.data.list) {
          this.buildingTypeList = res.data.list
          window.localStorage.setItem('platformBuildingTypeList', JSON.stringify(this.buildingTypeList))
        }
      }, err => {
        console.log(err)
      })
    },
  },
  async created () {//dom没渲染完成执行
    //避免进入基本信息页面先出现不是工业化项目页面,先清空
    if (this.$route.query.status !== 'create') this.objRowRequest.is_indust_project = ''
    await this.getOrgTree()//组织树
    this.isShowBtn()
    let businessTypeCodeList = window.localStorage.getItem('platformBusinessTypeCode')
    let buildingTypeList = window.localStorage.getItem('platformBuildingTypeList')
    // this.projectStatus = this.status
    this.projectStatus = this.$route.query.status;
    if (businessTypeCodeList) {
      this.businessTypeList = JSON.parse(businessTypeCodeList)
    } else {
      await this.getBusinessTypeCode()
    }
    if (buildingTypeList) {
      this.buildingTypeList = JSON.parse(buildingTypeList)
    } else {
      await this.getBuildingTypeCode()
    }
  },
  mounted () {
    this.getQrCode()//生成二维码
  }
}
</script>

<style scoped lang='scss'>
.addProject-container {
  background: #fff;
  .right-box {
    position: relative;
    .title-style {
      position: absolute;
      right: 10px;
      top: -1px;
      color: blue;
    }
  }
  .start-date-style {
    margin-top: 22px;
  }
  .common-row-style {
    display: flex !important;
    flex-direction: row !important;
  }
  .pro-name-style {
    display: flex;
    flex-direction: row;
  }
  .bind-project {
    margin-left: 20px;
  }
  .back {
    padding-left: 190px;
  }
  .pro-form {
    padding: 20px 0px;
    .normal-input {
      width: 100%;
    }
    /deep/ .avatar-uploader .el-upload {
      border: 1px dashed #d9d9d9;
      border-radius: 6px;
      cursor: pointer;
      position: relative;
      overflow: hidden;
    }
    .avatar-uploader .el-upload:hover {
      border-color: #409eff;
    }
    .avatar-uploader-icon {
      font-size: 28px;
      color: #8c939d;
      width: 178px;
      height: 178px;
      line-height: 178px;
      text-align: center;
    }
    .avatar {
      width: 178px;
      height: 178px;
      display: block;
    }
  }
  .pro-code-style {
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    position: relative;
    .imm-down {
      height: 36px;
      position: absolute;
      left: 150px;
      bottom: 0px;
    }
  }
  .el-date-editor {
    width: 100%;
  }
}
</style>